<template>
	<view>
		<!-- 自定义导航栏 -->
		<uni-nav-bar :statusBar="true" rightText="发布" left-icon="arrowleft" @click-left="back" @click-right="submit">
			<view class="u-f-ajc" @tap="change">
				{{ yinsi }}
				<view class="icon iconfont icon-xialazhankai"></view>
			</view>
		</uni-nav-bar>

		<!-- 多行输入框 -->
		<view class="uni-textarea"><textarea v-model="text" placeholder="说一句话吧~" /></view>

		<!-- 上传图片 -->
		<uploud-images @uploud="uploud"></uploud-images>
		
		<!-- 弹出公告 -->
		<uni-popup :show="showpopup" position="middle" mode="fixed" @hidePopup="hidePopup">
			<view class="gonggao">
				<view class="u-f-ajc">
					<image src="../../static/common/addinput.png" mode="widthFix"></image>
				</view>
				<view class="">1.涉及黄色，政治，及骚扰信息</view>
				<view class="">2.涉及黄色，政治，及骚扰信息</view>
				<view class="">3.涉及黄色，政治，及骚扰信息</view>
				<view class="">4.涉及黄色，政治，及骚扰信息</view>
				<button type="default" @tap="hidePopup">朕知道了</button>
				
			</view>
		</uni-popup>
		
		
	</view>
</template>

<script>
import uniNavBar from '../../components/uni-nav-bar/uni-nav-bar.vue';
import uploudImages from '../../components/common/uploud-images.vue';
import uniPopup from "../../components/uni-popup/uni-popup.vue"
let changelook = ['所有人可见', '仅自己可见'];
export default {
	components: {
		uniNavBar,
		uploudImages,
		uniPopup
	},
	data() {
		return {
			yinsi: '所有人可见',
			text: '',
			imglist:[],
			showpopup:true,
			isget:false
		};
	},
	// 监听页面返回
	onBackPress() {
		// 如果用户提交
		if(!this.text && this.imglist.length<1){
			return;
		}
		if(!this.isget){
			this.baocun()
		return true;
		}
	},
	methods: {
		// 保存为草稿、
		baocun(){
			uni.showModal({
				title:'是否要保存为草稿？',
				cancelText:'不保存',
				confirmText:'保存',
				success: res=> {
					if(res.confirm){
						console.log('保存');
						
					}else{
						console.log('不保存')
					}
					this.isget = true;
					uni.navigateBack({
						delta:1
					})
				}
				
			});
		},
		// 返回
		back() {
			uni.navigateBack({
				delta: 1
			});
		},
		// 发布事件
		submit() {
			console.log('发布');
		},
		// 隐私
		change() {
			console.log('隐私');
			uni.showActionSheet({
				itemList: changelook,
				success: res => {
					console.log('选中了' + (res.tapIndex + 1) + '个按钮');
					this.yinsi = changelook[res.tapIndex];
				},
				fail(res) {
					console.log(res.errMsg);
				}
			});
		},
		uploud(arr){
			this.imglist = arr;
			console.log(this.imglist)
		},
		hidePopup(){
			this.showpopup = false;
		}

	}
};
</script>

<style>
.u-f-ajc {
	margin: 0 auto;
}
.uni-textarea {
	border: 1upx solid #eeeeee;
}
.cell-pd {
	padding: 10upx 30upx;
}

.list-pd {
	margin-top: 50upx;
}
.gonggao{
	width: 500upx;
	z-index: 110;
}
.gonggao image{
	width: 80%;
	
	margin-bottom: 20upx;
}
.gonggao view{
	padding-left: 40upx;
}
.gonggao button{
	background-color: #FFE934;
	color: #171606;
	margin-top: 20upx;
}
	
</style>
